package com.kfm.jdbc.day0405;

import java.util.concurrent.CountDownLatch;

public class Demo10 {


    public static void main(String[] args) {
        CountDownLatch count = new CountDownLatch(5);

        new Thread(new Runnable() {
                    @Override
                public void run() {
                    try {
                        count.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("线程1");
                }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    count.await();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("线程2");
            }
        }).start();

        try {
            Thread.sleep(3000);
            count.countDown();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
